<template>
  <div>
    <CompAVue />
    <CompBVue />
    <van-button type="primary" @click="handleTea">转存数据</van-button>
  </div>
</template>

<script setup lang="ts">
import CompAVue from "./PiniaDemo/CompA.vue";
import CompBVue from "./PiniaDemo/CompB.vue";
import axios from "axios";
import request from "../../utils/request";
// 测试易宠接口
// let url = `/epet/v3/goods/category/main.html?pet_type=dog&version=358&system=wap&isWeb=1&distinct_id=18103a1b05c1ad-0e912bb23fd759-4c647e53-1474560-18103a1b0634e5&_=1667352172918`;
// axios.get(url).then((res) => {
//   console.log(res);
// });

// 测试茶7的post接口
const handleTea = () => {
  const options = {
    method: "POST",
    url: "/tea7/API/Product/GetProductRecommend",
    data: { groupName: "IndexGuessYouLike", notproductIds: "" },
  };

  axios.request(options).then(function (response) {
    console.log(response.data);
    let arr = response.data.map((item: any) => {
      return {
        method: "POST", //批量存储
        path: "/1.1/classes/Tea7", //转存位置表
        body: item, //被转存的每一条数据
      };
    });
    request.post("/batch", { requests: arr }); //批量转存至LeanCloud
  });
};

// 测试跑腿
// const options = {
//   method: "POST",
//   url: "https://m.uupt.com/fewebapi/UserSearch/BeforeAddOrder",
//   params: { t: "1667354223610" },
//   headers: { token: "e32391a079664cdf9752e2bffc15d839" },
//   data: {
//     data: "TEDhZpLFs05MDqVQ2bhG1ePnyhKpfkUoj4XkzGYHuaLjagD3U6nHNumhveDOr+m8d3VPOHZmxKv2azeT5I7xM5igSN+JHVYkBloD5h4x0ah9xToPwLb7RzDfL+Sl1JIu7flH3ysAc2hoq02N9Jt/l7hnxUmCLQRlRoUDVx8OwfKvScRJfOMa83vOgU2f1xHLoTi8bn+BorUqYRV5BPyG1w==",
//   },
// };

// axios
//   .request(options)
//   .then(function (response) {
//     console.log(response.data);
//   })
//   .catch(function (error) {
//     console.error(error);
//   });
</script>

<style scoped></style>
